% GAUTIER LE BIHAN - 2020
% Replication files for "Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector 
% Menu-Cost Model" Review of Economics and Statistics
% This code produces Plots for Appendix figure C and D from stored moments


clear all
close all
clear matrix
clc


cd ..\..\Simu_identification\sim_param_moments_lambda0

load stat_outk1.mat 
load stat_outk2.mat 
load stat_outk3.mat 

cd ..\..\Simu_identification\sim_param_moments_baseline_append
load stat_outsample_1118egb.mat 

%stat1=stat_out(:,2:end);
stat1=stat_outsample_1118egb(:,2:end);
stat2=stat_out(:,2:end);
stat3=stat_outb(89:176,2:end);
stat4=stat_outc(177:264,2:end);;

%% The first 4 columns are the parameters
params_vec=stat1(:, 1:4)   ;
params_vec2=stat2(:, 1:4)   ;

%% The first folllowing columns are the moments
moments_vec=stat1(:, 5:end)  ;
moments_vec2=stat2(:, 5:end)  ;
moments_vec3=stat3(:, 5:end)  ;
moments_vec4=stat4(:, 5:end)  ;

%%%%%%
disp( '%%%%%%%%%%%%%%%%    Parameters value for the baseline case   %%%%%%%%%%%%%%%%%%%%%%%%%%');
rho_base =0.653430547029268;
p0_base = 0.0490191241633841;
mu_c_base =0.0315640909562270;
sig_eps_a_base = 0.0191196154604684*2;

param_plot =2;

figure(1);
%%% Vector of mu_c, holding other parameters to their default values
aa = abs(params_vec(:,1)- p0_base);
aa_min = min(aa);
% bb = abs(params_vec(:,3)-sig_c_base );
% bb_min = min(bb);
cc = abs(params_vec(:,3)-sig_eps_a_base );
cc_min = min(cc);
dd = abs(params_vec(:,4)-rho_base );
dd_min = min(dd);
plot_vec = (aa==aa_min)&(cc==cc_min)&(dd==dd_min);

%min(params_vec(:,2))
%max(params_vec(:,2))

hold on;
mygraph=plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-k',params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,6), '--r',params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,7), '--b');
 set(mygraph,'Linewidth',2);


axis([min(params_vec(:,2)) max(params_vec(:,2))  0.0 0.09])
xlabel('\mu') % x-axis label
ylabel('Median price changes') % y-axis label
legend('All price changes','Menu Cost price changes', 'Free price changes');
hold off;
 % print('..\..\..\figures\figure_median_appendix1.pdf','-dpdf','-fillpage')
 


figure(2)
hold on;
mygraph=plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,6), '-k', params_vec(plot_vec~=0,param_plot),moments_vec3(plot_vec~=0,6), '-ok',params_vec(plot_vec~=0,param_plot),moments_vec4(plot_vec~=0,6), '--k');
%plot(params_vec(plot_vec~=0,param_plot),moments_vec2(plot_vec~=0,3),'-ok');%'Small \sigma',

 set(mygraph,'Linewidth',2);

axis([min(params_vec(:,2)) max(params_vec(:,2))  0.0 0.09])
xlabel('\mu') % x-axis label
ylabel('Median price changes') % y-axis label
legend('All price changes', 'No free price changes', 'Small \sigma and No free price changes');
hold off;

%  print('..\..\..\figures\figure_median_appendix2.pdf','-dpdf','-fillpage')



